﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace 天离安卓权限维持系统.Services
{
    public class GetInterIp_Services
    {
        public async static Task<string> GetIp()
        {
            using (HttpClient client = new HttpClient())
            {
                try
                {
                    // 使用另一个提供公网IP的API服务
                    string ip = await client.GetStringAsync("https://checkip.amazonaws.com");
                    ip = ip.Trim();
                    Api.Public_Api.Ip = ip.ToString();
                    return ip;
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"获取公网 IP 地址时出错: {ex.Message}");
                    return null;
                }
            }
        }
    }
}
